package com.sg.bars.webapp.example;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sg.bars.client.example.action.ExampleAction;
import com.sg.bars.client.kernel.action.ActionException;
import com.sg.bars.client.kernel.service.DataService;

@ManagedBean
@ViewScoped
public class RichBean implements Serializable {
	
	private static Logger logger = LoggerFactory.getLogger(RichBean.class);
	
	@ManagedProperty(value="#{dataService}")
	private DataService dataService;

    private static final long serialVersionUID = -2403138958014741653L;
    private String name;

    public RichBean() throws ActionException {
        System.out.println("post construct: initialize");
        name = "John";
    }

    public String getName() throws ActionException {
    	ExampleAction ea = new ExampleAction(1l);
    	dataService.doAction(ea);
    	if (logger.isDebugEnabled()){
    		logger.debug("asfasfasfasf");
    	}
    	System.out.println(ea.getExampleId());
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

	public void setDataService(DataService dataService) {
		this.dataService = dataService;
	}

	public DataService getDataService() {
		return dataService;
	}
}
